package com.eco.fanliapp.service;


import com.baomidou.mybatisplus.extension.service.IService;
import com.eco.fanliapp.common.response.ServerResponse;
import com.eco.fanliapp.entity.SyChannel;
import com.eco.fanliapp.vo.SyChannelGroupVo;
import com.eco.fanliapp.vo.SyChannelUserVO;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * <p>
 * 渠道表 服务类
 * </p>
 *
 * @author jobob
 * @since 2019-08-21
 */
public interface ISyChannelService extends IService<SyChannel> {

    /**
     * 根据渠道邀请码获取渠道
     * @param channelInviteCode
     * @param type 1优先从redis获取0从数据库中获取
     * @return
     */
    SyChannel findSyChannelUserById(String channelInviteCode, int type);

    /**
     * 渠道管理生成
     *
     * @param inviteCode
     * @return
     */
    String linkCreate(String inviteCode, Integer companyId);

    /**
     * 渠道管理生成
     *
     * @param inviteCode
     * @return
     */
    String linkCreateNew(String inviteCode, Integer companyId);

    /**
     * 渠道关系统计
     *
     *
	 * @param currentPage
	 * @param pageSize
	 * @param companyId
	 * @param searchDate
	 * @return
     */
    ServerResponse manageStatistical(int currentPage, int pageSize, Integer companyId, String searchDate,String keyWord);

    /**
     * 导出渠道统计
     *
     * @param response
     * @param companyId
     * @param searchDate
     * @return
     */
    void exportManageStatistical(HttpServletResponse response, Integer companyId, String searchDate);

    /**
     * 渠道统计下详情
     *
     * @param currentPage
     * @param pageSize
     * @param channelId
     * @return
     */
    ServerResponse statisticalDetail(int currentPage, int pageSize, Long channelId);

    /**
     * 渠道统计下详情导出
     *
     * @param response
     * @param channelId
     */
    void exporttatisticalDetail(HttpServletResponse response, Long channelId);

    SyChannel getByTableId(long tableId);

	/**
	 * 判断上级是否是渠道下人
	 * @param userId
	 * @return
	 */
	SyChannel findSyChannelByUserId(Long userId);

	List<SyChannelUserVO> manageStatisticalNew(Integer companyId, String searchDate);


	List<SyChannelUserVO> statisticalDetailNew(Long channelId);

	/**
	 * 根据渠道组获取渠道集合
	 * @param groupId
	 * @return
	 */
	List<Integer> findChannelListByGroupId(Integer groupId);

	/**
	 *
	 * @param channelList
	 * @param startTime
	 * @param endTime
	 * @return
	 */
	List<SyChannelGroupVo> groupList(List<Integer> channelList, Long startTime, Long endTime);

	/**
	 * 各渠道下数据统计
	 * @param groupId
	 * @param startTime
	 * @param endTime
	 * @return
	 */
	List<SyChannelGroupVo> channelDetailList(Integer groupId, Long startTime, Long endTime, String channelName);


	/**
	 * 清除指定渠道下缓存
	 * @param channelId
	 */
	void clearDate(Long channelId);

	void handleDate(Integer companyId);

	void handleNotChannel(Integer companyId);
}
